﻿

namespace ToyChat.BuiltinModules
{
    /// <summary>
    /// This interface describes a common way to handler permissions
    /// </summary>
    public interface IPermissionsHandler
    {
        /// <summary>
        /// Checks the permissions of the user with the specified UserID on the channel with the specfieid ChannelID for the specified Permissions
        /// </summary>
        /// <param name="username">The username of the user to check permissions for</param>
        /// <param name="channelID">The ID of the channel to check permissions for</param>
        /// <param name="permissions">The permissions to check for</param>
        /// <returns>True if the user has the specified permissions, otherwise false</returns>
        bool CheckPermissions(string username, int channelID, ChannelPermissionFlags permissions);

        /// <summary>
        /// Attempts to get the permissions for the user with the specified UserID on the channel with the specified ChannelID
        /// </summary>
        /// <param name="username">The username of the user to get permissions for</param>
        /// <param name="channelID">The ID of the channel to get permissions for</param>
        /// <returns>An <see cref="UserPermissions"/> object containing the permissions of the user if succesful, otherwise a TimeoutException is thrown</returns>
        UserPermissions GetPermissions(string username, int channelID);

        /// <summary>
        /// Stores the specified <see cref="DefaultChannelPermissions"/> in the database
        /// </summary>
        /// <param name="permissions">The permissions to store</param>
        void StorePermissions(DefaultChannelPermissions permissions);


        /// <summary>
        /// Stores the specified <see cref="UserPermissions"/> in the database
        /// </summary>
        /// <param name="permissions">The permissions to store</param>
        void StorePermissions(UserPermissions permissions);
    }
}